import ActionTypes from '../config/ActionTypes';
import Session from '../utils/SessionUtils';
import {AsyncStorage}from 'react-native'

const initState = {
	isSuccess: false,
	isAddCommentSuccess: false,
	comments: [],
};

const commentReducer = (state = initState, action) => {
	switch (action.type) {
		case ActionTypes.COMMENTLIST + ActionTypes.FETCH_LOADING_SUFFIX:
			{
				return {
					...state,
					isSuccess: false,
					isAddCommentSuccess: false,
				};
			}
			break;
		case ActionTypes.COMMENTLIST + ActionTypes.FETCH_SUCCESS_SUFFIX:
			{            
				return {
					...state,
					isSuccess: true,
					comments: action.items,
					isAddCommentSuccess: false,
				};
			}
			break;
		case ActionTypes.COMMENTLIST + ActionTypes.FETCH_ERROR_SUFFIX:
			{
				return {
					...state,
					isSuccess: false,
					isAddCommentSuccess: false,
				};
			}
			break;
			case ActionTypes.COMMENT + ActionTypes.FETCH_SUCCESS_SUFFIX:
			{
				return {
					...state,
					isAddCommentSuccess: true,
				};
			}
			break;
		default:
			{
				return state;
			}
			break;
	}
};


export default commentReducer;